Tcl_Obj *
SWIG_Ptr2Obj(Tcl_Interp *interp,const char *classstr,
             struct swig_type_info *swig_type,void *source)
{
    char name[512];
    Tcl_CmdInfo dummy;
    if (source==NULL)
        return Tcl_NewStringObj("",-1);
    else{
        Tcl_CmdInfo info;
        Tcl_Obj *newObj;
        SWIG_MakePtr(name,(void *)source,swig_type);
        Tcl_GetCommandInfo(interp,(char*)classstr,&info);
        struct swig_class *classptr=(struct swig_class *)info.objClientData;
        newObj=Tcl_NewStringObj(name,-1);
        if (!Tcl_GetCommandInfo(interp,name,&dummy)) {
           void *thisvalue=0;
           swig_instance *newinst;
           if (SWIG_ConvertPtr(interp,newObj, (void **) &thisvalue,  
                   *(classptr->type)) == TCL_ERROR) {
              Tcl_DecrRefCount(newObj);
              return NULL;
           }
           newinst = (swig_instance *) malloc(sizeof(swig_instance));
           newinst->thisptr = newObj;
           Tcl_IncrRefCount(newObj);
           newinst->thisvalue = thisvalue;
           newinst->classptr = classptr;
           newinst->destroy = 0;
           Tcl_CreateObjCommand(interp,name, SwigMethodCmd, 
                (ClientData) newinst, SwigObjectDelete);
        }
        return newObj;
    }
}